const mysql = require('mysql')
const pool = mysql.createPool({
    host:'localhost',user:'root',password:'root',database:"vvdatabass"
})
function exec(sql,params) {
    return new Promise(function (resolve,reject) {
        pool.getConnection(function (err,conn) {
             if(err){
                console.log('连接数据库失败'+ err.message);
                reject(err.message)
            }
            conn.query(sql,params,function (err,results) {
                if(err){
                    console.log('sql查询错误'+err.message);
                    reject(err.message)
                }
                resolve(results)
                conn.release()
            })
        })
       
    })
    
}
module.exports = { exec }// 
// module.exports.exec=exec